package com.java.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.java.admin.mapper.AdminUserMapper;
import com.java.admin.param.AdminUserParam;
import com.java.admin.pojo.AdminUser;
import com.java.admin.service.AdminUserService;
import com.java.clients.UserClient;
import com.java.constants.UserConstants;
import com.java.param.PageParam;
import com.java.utils.MD5Util;
import com.java.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AdminUserServiceImpl implements AdminUserService {
    @Autowired
    private AdminUserMapper adminUserMapper;
    @Autowired
    private UserClient userClient;
    /**
     * 根据账号密码验证登录
     *
     * @param adminUserParam
     * @return
     */
    @Override
    public AdminUser login(AdminUserParam adminUserParam) {
        String password = MD5Util.encode(adminUserParam.getUserPassword()+ UserConstants.USER_SLAT);
        QueryWrapper<AdminUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_account",adminUserParam.getUserAccount());
        queryWrapper.eq("user_password",password);
        log.info("AdminUserServiceImpl.login 业务已经完成,结果:{}", password);
        AdminUser adminUser = adminUserMapper.selectOne(queryWrapper);
        log.info("AdminUserServiceImpl.login 业务已经完成,结果:{}", adminUser);
        return adminUser;
    }

}
